<template>
    <!--健康码动态日志-->
    <dv-scroll-board :config="config" style="width:100%;height:100%;" >
    </dv-scroll-board>
</template>

<script>
    export default {
        name: "index",
        data() {
            return {
                data: [],
                // 定时刷新数据任务
                refreshHandle: null,
            }
        },
        computed: {
            config(){
                let {data} = this;
                return {
                    rowNum: 5,
                    headerBGC: '',
                    oddRowBGC: '',
                    evenRowBGC: '',
                    waitTime: 5000,
                    header: ['区域', '姓名', '操作', '健康状态'],
                    data: data,
                    index: true,
                    columnWidth: [40, 70, 80],
                    align: ['center'],
                    carousel: 'page'
                };
            },
        },
        created(){
            this.findList();
            this.refreshHandle = setInterval(()=>{
                this.findList();
            }, 5000);
        },
        beforeDestroy(){
            if (this.refreshHandle) {
                clearInterval(this.refreshHandle);
            }
        },
        methods: {
            // 查询数据
            findList(){
                let data = {
                    page: 1,
                    pageSize: 20
                };
                this.$api.codeLog.query(data).then(({data}) => {
                    let records = data.records || [];
                    let list = records.map(item=>{
                        return [
                            item.areaName, item.userName, item.title, item.healthState
                        ];
                    });
                    this.data = list;
                });
            },
        },
    }
</script>

<style scoped>

</style>
